﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LiveSequence.Common.Domain;
using LiveSequence.Suite.Documents;
using LiveSequence.Suite.Domain;
using LiveSequence.Suite.Helpers;
namespace LiveSequence.Suite.Commands
{
  public class ExtendDiagramCommand : DocumentCommand<SeqDiagramDoc>
  {
    public ExtendDiagramCommand(SeqDiagramDoc document) : base(document)
    {

    }

    #region Overrides
    public override string Text(object arg)
    {
      return "Extend Diagram";
    }

    public override bool Execute(object arg)
    {
      MethodCallInfo methodCallInfo = arg as MethodCallInfo;

      ProjectDoc projectDoc = DocManager.Instance.MasterDocument;

      LSMethodCallDiagram diagram = CloneHelper<LSMethodCallDiagram>.Clone(Document.Diagram);
      SeqDiagramDoc seqDiagramDoc = new SeqDiagramDoc(Document.Diagram);

      if (projectDoc != null)
      {
        projectDoc.AddDiagram(seqDiagramDoc);
      }

      DocManager.Instance.ActiveDocument = seqDiagramDoc;

      return true;
    }

    public override bool CanExecute(object arg)
    {
      return false;
    }

    #endregion
  }
}
